<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <a href="http://www.baidu.com">去百度</a>
    <a href="http://www.qq.com">去qq</a>
    <script>
        var oA=document.querySelectorAll("a");
        oA[0].onclick=function(){
            return false;
        }

        oA[1].onclick=function(evt){
            var e=evt||window.event;
            if(e.preventDefault){
                e.preventDefault();
            }
            else{
                e.returnValue=false;
            }
        }
    </script>
</body>
</html>